require(["dojo/_base/declare", "dijit/_Widget"],function(declare, _Widget){
declare("market.widgets.Cache", [_Widget], {
   _dataSource:{},
   _numberItemCaches:0,
   _maxItemsNumber:0,
   constructor:function(args){
      this._maxItemsNumber = args.maxItems;
   },
   addItem:function(key, value){
      if (this._numberItemCaches <= this._maxItemsNumber && this._dataSource[key] == null){
         this._dataSource[key] = value;
         this._numberItemCaches ++;
      }
   },
   setItem:function(key, value){
      if (this._dataSource[key] != null){
         this._dataSource[key] = value;
      }
   },
   getValue:function(key){
      return this._dataSource[key];
   },
   containKey:function(key){
      if (this._dataSource[key] == null){
         return false;
      }
      return true;
   },
   clear:function (){
      this._dataSource = {};
   }
})});
